/**
 * 路由整合
 * 通过import达到异步加载的效果
 * import 传参中的注释 (webpackChunkName)用于命名打包之后的js文件， 在控制台的打包结果输出里面会输出名字
 * 同时修改 build/webpack.prod.conf.js chunkFilename: utils.assetsPath('js/[name].[chunkhash].js') 中的name 生成的文件也会按你的注释命名
 * 如果不写注释将按默认的id + hash 命名 ， id及项目中页面/组件打包从头到尾的顺序来定义 
 *  https://webpack.js.org/guides/code-splitting/
 * 
 * 
 * name 通常会成为 document.title 也就是微信窗口标题
 * @summary 相关路由整合文件
 * @author LinRenChen
 *
 * Created at     : 2018-09-09 00:45:24 
 * Last modified  : 2019-04-19 00:20:40
 */
import Vue from 'vue/dist/vue.js';
import Router from 'vue-router';

Vue.use(Router);

// import routeHack from './routeHack'; //导入兼容方案

const TEMPLATE = {
    template: '<router-view></router-view>'
}

import orderIndex from './../views/order/index';
import saleIndex from './../views/sale/index';

/**
 * meta { 
 *     header: 'show' / 'hidden' 头部不显示， 默认显示 需要显示直接不声明此字段     show 属性可以忽略不写
 *     back: 'show' / 'hidden' 返回按钮不现实， 默认显示 需要显示直接不声明此字段   show 属性可以忽略不写
 *     backText: String 返回按钮文字， 默认不显示文字
 *     footer: 'show' / 'hidden' 底部table 默认不显示底部的按钮组， 需要显示就声明此字段  hidden 属性可以忽略不写
 * }
 */
let router =  new Router({
    routes: [{
        path: '/',
        redirect: '/index' // 确定第一个页面展示
    },{
        path: '/test', // 页面路由示例
        component: () => import('./../views/test.vue'),
        meta: {
            header: 'hidden',
            footer: 'hidden'
        }
    }, {
        path: '/login',
        // name: '登录',
        leftText: '',
        component: () => import('./../views/login/login.vue'),
        meta: {
            header: 'show'
        }
    }, {
        path: '/regist',
        name: '注册',
        component: () => import('./../views/login/regist.vue'),
    }, {
        path: '/forget',
        name: '忘记密码',
        component: () => import('./../views/login/forget.vue')
    }, {
        path: '/index',
        name: '首页',
        component: () => import('./../views/index.vue'),
        meta: {
            header: 'hidden',
            footer: 'show',
        }
    }, {
        path: '/classify',
        name: '分类',
        meta: {
            header: 'hidden',
            footer: 'show',
        },
        component: () => import('./../views/classify/classify.vue')
    }, {
        path: '/kefu',
        name: '客服',
        meta: {
            header: 'hidden',
            footer: 'show',
        },
        component: () => import('./../views/mine/kefu.vue')
    }, {
        name: '交易中心',
        path: '/transaction',
        meta: {
            header: 'hidden',
            footer: 'show',
        },
        component: () => import('./../views/transaction/transaction.vue')
    }, {
        path: '/shopCar',
        name: '购物车',
        component: () => import('./../views/shopCar/shopCar.vue'),
        // meta: {
        //     footer: 'show',
        // }
    }, {
        path: '/shopCarPage',
        name: '购物车页面',
        component: () => import('./../views/shopCar/shopCar.vue'),
    }, {
        path: '/mine',
        name: '我的',
        component: () => import('./../views/mine/mine.vue'),
        meta: {
            header: 'hidden',
            footer: 'show',
        }
    }, {
        path: '/mine/info',
        name: '账号管理',
        component: () => import('./../views/mine/info.vue')
    }, {
        path: '/mine/edit',
        name: '修改个人信息',
        component: () => import('./../views/mine/edit.vue')
    }, {
        path: '/mine/edit/realName',
        name: '修改真实姓名',
        component: () => import('./../views/mine/editGroup/realName.vue')
    }, {
        path: '/mine/edit/birthday',
        name: '修改生日',
        component: () => import('./../views/mine/editGroup/birthday.vue')
    }, {
        path: '/mine/edit/sex',
        name: '修改性别',
        component: () => import('./../views/mine/editGroup/sex.vue')
    }, {
        path: '/mine/edit/weixin',
        name: '修改微信',
        component: () => import('./../views/mine/editGroup/weixin.vue')
    }, {
        path: '/mine/edit/address',
        name: '修改地区',
        component: () => import('./../views/mine/editGroup/address.vue')
    }, {
        path: '/mine/edit/avatar',
        name: '修改头像',
        component: () => import('./../views/mine/editGroup/avatar.vue')
    }, {
        path: '/sale',
        component: saleIndex,
        redirect: '/sale/list',
        children: [{
            path: 'list',
            name: '销售列表',
            component: () => import('./../views/sale/list.vue')
        }]
    },{
        path: '/goods',
        component: TEMPLATE,
        redirect: '/goods/list',
        children: [{
            path: 'list',
            name: '商品列表',
            component: () => import('./../views/goods/list.vue'),
            meta: {
                header: 'hidden',
            }
        }, {
            path: 'goodsType/:id',
            name: '商品分类',
            meta: {
                header: 'show',
            },
            component: () => import('./../views/goods/goodsType.vue')
        }, {
            path: 'detail/:id',
            name: '商品详情',
            meta: {
                header: 'hidden',
            },
            component: () => import('./../views/goods/detail.vue')
        }, {
            path: 'noGoodsdata',
            name: '商品不存在',
            component: () => import('./../views/goods/noGoodsdata.vue'),
            meta: {
                back: 'hidden'
            }
        }, {
            path: 'comment/:id',
            name: '评论列表',
            component: () => import('./../views/goods/comment.vue')
        }, {
            path: 'collection',
            name: '收藏列表',
            component: () => import('./../views/goods/collectionList.vue')
        }]
    }, {
        path: '/address',
        component: TEMPLATE,
        redirect: '/address/list',
        children: [{
            path: 'list',
            name: '地址管理',
            component: () => import('./../views/address/list.vue')
        }, {
            path: 'add',
            name: '新建收货地址',
            component: () => import('./../views/address/add.vue')
        }, {
            path: 'edit',
            name: '修改地址',
            component: () => import('./../views/address/edit.vue')
        }]
    }, {
        path: '/shopActivity',
        component: TEMPLATE,
        redirect: '/shopActivity/discountCard',
        children: [{
            path: 'getDiscountCard',
            name: '领取优惠券',
            component: () => import('./../views/shopActivity/getDiscountCard.vue')
        }, {
            path: 'discountCard',
            name: '优惠券',
            component: () => import('./../views/shopActivity/discountCard.vue')
        }, {
            path: 'elseActivity',
            name: '其他活动',
            component: () => import('./../views/shopActivity/elseActivity.vue')
        }, {
            path: 'rechargeTraffic',
            name: '流量充值',
            component: () => import('./../views/shopActivity/rechargeTraffic.vue')
        }, {
            path: 'rechargeTrafficDetail/:id',
            name: '流量充值',
            component: () => import('./../views/shopActivity/rechargeTrafficDetail.vue')
        }]
    }, {
        path: '/order',
        component: orderIndex,
        redirect: '/order/list',
        children: [{
            path: 'list',
            name: '订单列表',
            component: () => import('./../views/order/list.vue')
        }, {
            path: 'payOrder',
            name: '确认订单',
            component: () => import('./../views/order/payOrder.vue')
        }, {
            path: 'expressList',
            name: '查看物流',
            component: () => import('./../views/order/expressList.vue')
        }, {
            path: 'detail/:id',
            name: '订单详情',
            component: () => import('./../views/order/detail.vue')
        }, {
            path: 'commentList/:id',
            name: '商品选择',
            component: () => import('./../views/order/commenList.vue')
        }, {
            path: 'comment/:id',
            name: '订单评论',
            component: () => import('./../views/order/comment.vue')
        }, {
            path: 'refundList',
            name: '售后列表',
            component: () => import('./../views/order/refundList')
        }, {
            path: 'refundDetail/:id',
            name: '退款详情',
            component: () => import('./../views/order/refundDetail')
        }, {
            path: 'refund/:id',
            redirect: 'refund/:id/way',
            component: () => import('./../views/order/refund'),
            children: [{
                name: '选择退款方式',
                path: 'way',
                component: () => import('./../views/order/refunds/way.vue')
            }, {
                name: '仅退款',
                path: 'tuikuan',
                component: () => import('./../views/order/refunds/tuikuan')
            }, {
                name: '退货退款',
                path: 'tuihuo',
                component: () => import('./../views/order/refunds/tuihuo')
            }]
        }]
    }, {
        path: '/notice',
        redirect: '/notice/list',
        component: () => import('./../views/notice/index.vue'),
        children: [{
            path: 'list',
            name: '通知列表',
            component: () => import('./../views/notice/list.vue')
        }, {
            path: 'detail/:id',
            name: '通知详情',
            component: () => import('./../views/notice/detail.vue')
        }]
    }, {
        path: '/capital',
        component: TEMPLATE,
        redirect: '/capital/index',
        children: [{
            name: '我的钱包',
            path: 'index',
            component: () => import('./../views/capital/capitalList.vue')
        }, {
            name: '资产详情',
            path: 'detail',
            meta: {red: true},
            component: () => import('./../views/capital/detail.vue')
        }, {
            name: '提现',
            path: 'withdrawal',
            component: () => import('./../views/capital/withdrawal.vue')
        }]
    }, {
        path: '/editPassword',
        component: TEMPLATE,
        redirect: '/editPassword/login',
        children: [{
            name: '修改登录密码',
            path: 'login',
            component: () => import('./../views/editPassword/loginPwd.vue')
        }, {
            name: '修改支付密码',
            path: 'pay',
            component: () => import('./../views/editPassword/payPwd.vue')
        }]
    }, {
        path: '/resetPassword',
        component: TEMPLATE,
        redirect: '/resetPassword/pay',
        children: [{
            name: '重置支付密码',
            path: 'pay',
            component: () => import('./../views/editPassword/reset/payPwd.vue')
        }]
    }]
});
// routeHack(router);

export default router;